//
//  PreparePregnancyController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/28.
//

#import "PreparePregnancyController.h"
#import "CustomDateViewController.h"

@interface PreparePregnancyController ()

@end

@implementation PreparePregnancyController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"备孕期";
    self.view.backgroundColor = BACKGROUNDCOLOR;
}

- (void)initSubviews {
    [super initSubviews];
    
    MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    root.myHorzMargin = 15;
    root.myTop = 15 + NavigationContentTop;
    root.myHeight = kAutoHeight;
    [self.view addSubview:root];
    
    MyLinearLayout *contentLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    contentLay.myHorzMargin = 0;
    contentLay.padding = UIEdgeInsetsMake(0, 15, 0, 15);
    contentLay.backgroundColor = COLOR_4;
    contentLay.layer.cornerRadius = 15;
    contentLay.myHeight = kAutoHeight;
    [root addSubview:contentLay];
    
    NSArray *array = @[@"周期长度",@"经期长度",@"上次月经",@"经期开始提醒",@"设备提醒",@"提醒时间"];
    for (int i = 0; i < array.count; i++) {
        MyLinearLayout *itemLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        itemLay.myHorzMargin = 0;
        itemLay.gravity = MyGravity_Vert_Center;
        itemLay.myHeight = 52;
        itemLay.tag = 10 + i;
        [contentLay addSubview:itemLay];
        [itemLay setTarget:self action:@selector(itemLayClick:)];
        
        if(i < array.count - 1)[contentLay addSubview:[self setAddLineTop:0]];
        
        {
            
            UILabel *name = [UILabel createLabelText:array[i] font:UIFontMake(15) textColor:COLOR1515];
            name.myHeight = kAutoHeight;
            name.weight = 1;
            [itemLay addSubview:name];
            
            if(i == 4){
                UISwitch *sw = [[UISwitch alloc]init];
                sw.mySize = kAutoSize;
                sw.on = YES;
                sw.onTintColor = THEME_COLOR;
                [itemLay addSubview:sw];
            }else{
                QMUITextField *tf = QMUITextField.new;
                tf.mySize = kAutoSize;
                tf.enabled = NO;
                NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"请选择" attributes:
                                                             @{NSForegroundColorAttributeName:HexColor(@"#BABABA"),
                                                               NSFontAttributeName:UIFontMake(15)}
                ];
                tf.attributedPlaceholder = attrString;
                [itemLay addSubview:tf];
                
                UIImageView *right = [[UIImageView alloc]initWithImage:UIImageMake(@"icon_arrow_right")];
                right.mySize = CGSizeMake(16, 16);
                [itemLay addSubview:right];
            }
            
            
        }
    
    }
    
    
    UIButton *submitBtn = [UIButton createButtonText:@"开始备孕模式" font:UIFontMake(14) textColor:COLOR_4];
    submitBtn.myHorzMargin = 0;
    submitBtn.myTop = 30;
    submitBtn.myHeight = 46;
    ViewCorner(submitBtn, 23);
    [submitBtn az_setGradientBackgroundWithColors:@[HexColor(@"#4BD8B1"),HexColor(@"#2CAED8")] locations:@[@0.0,@1.0] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5)];
    [submitBtn addTarget:self action:@selector(submitBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [root addSubview:submitBtn];
}

- (void)itemLayClick:(UIView *)view {
    
}

- (void)submitBtnClick {
    CustomDateViewController *vc = CustomDateViewController.new;
    vc.title = self.title;
    [self showViewController:vc sender:self];
}

@end
